package com.cskaoyan.controller.vx.wangdi;


import com.cskaoyan.bean.Address;
import com.cskaoyan.bo.vx.wangdi.DeleteId;
import com.cskaoyan.bo.vx.wangdi.DetailBo;
import com.cskaoyan.bo.vx.wangdi.RegionListBo;
import com.cskaoyan.bo.vx.wangdi.VxAddressBo;
import com.cskaoyan.service.vx.wangdi.VxAddressService;
import com.cskaoyan.vo.BaseRespVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class VxAddressController {
    @Autowired
    VxAddressService vxAddressService;

    @RequestMapping("wx/address/list")
    public BaseRespVo addressList(){
        VxAddressBo list = vxAddressService.list();
        return new BaseRespVo().ok(list.getAddresses());
    }

    @RequestMapping("wx/address/delete")
    public BaseRespVo delete(@RequestBody DeleteId deleteId){

        vxAddressService.delete(deleteId.getId());
        return  new BaseRespVo().ok();
    }

//    @RequestMapping("/wx/region/list")
//    public BaseRespVo regionList(@Param("pid") Integer pid){
//        System.out.println(pid);
//        RegionListBo regionListBo = vxAddressService.regionList(pid);
//        return new BaseRespVo().ok(regionListBo.getRegions());
//    }

    @RequestMapping("wx/address/save")
    public BaseRespVo addressSava(@RequestBody Address address){
        vxAddressService.sava(address);
        return BaseRespVo.ok();
    }

    @RequestMapping("wx/address/detail")
    public BaseRespVo detail(@Param("id") Integer id){
        DetailBo detailBo = vxAddressService.detail(id);
        return BaseRespVo.ok(detailBo);
    }
}
